package cn.laixueit;

import java.util.Arrays;

public class Demo3 {
    public static void main(String[] args) {
//        String str = "abcd";
        /*char c = str.charAt(6);//不能超出索引，同数组一样会越界
        System.out.println(c);*/
        /*char a = str.charAt(0);
        char b = str.charAt(5);
        System.out.println(a);
        System.out.println(b);*/
        /*for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            System.out.println(c);
        }*/

        /*
        * 数组有没有length方法:x :数组只有length属性
        * 字符串有没有length方法:o
        * */
        /*int[] arr = new int[5];
        System.out.println(arr.length);*/

//        String s = str.concat("ef");
//        System.out.println("新"+s);
//        System.out.println("旧"+str);

        /*String s1 = s.concat(null);
        System.out.println(s1);*/
//        String str = "abcd";
        /*str = str +"efg";
        System.out.println(str);*/
        /*boolean b = str.contains("abd");
        System.out.println(b);
        char[] chars = new char[2];
        chars[0]='a';
        chars[1]='b';
        String newstr = str.copyValueOf(chars);
        System.out.println(newstr);
        //
        String s = String.copyValueOf(chars);
        System.out.println(s);*/

        /*
            String str = "abcd.jpg";
            boolean b = str.endsWith(".gif");
            System.out.println(b);
        */

      /*  String str = "abcdef";
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes) );
        // 将字节数组传递给NWE sTRING可以的到一个字符串
        String s = new String(bytes);
        System.out.println(s);*/
        String str = "abcdefg";
//        int index = str.indexOf("der");//-1
//        System.out.println(index);

        // 判断一个邮箱的格式是否正确?
        // 32dsasd@qq.cn // @ .
        str = "123456@qq.com";//"123456@qq.com"
        int index1 = str.indexOf("@");
        int index2 = str.indexOf(".");
        if(str.contains("qq")){
            if(index1 != -1 && index2 != -1){
                if(index2 > index1 && index2-index1==3){
                    System.out.println("正确QQ邮箱格式");
                }
            }
        }
    }
}
